package com.muse.patterns.strategy.duck;

import com.muse.patterns.strategy.fly.FlyBehavior;
import com.muse.patterns.strategy.quack.QuackBehavior;

/**
 * @description 鸭子抽象类
 * @author: muse
 **/
public abstract class Duck {
    protected FlyBehavior flyBehavior; // 飞行行为
    protected QuackBehavior quackBehavior; // 叫声行为

    public abstract void display();

    public void swin() {
        System.out.println("鸭子游泳");
    }

    public void quack() {
        quackBehavior.quack();
    }

    public void fly() {
        flyBehavior.fly();
    }

    public void setFlyBehavior(FlyBehavior flyBehavior) {
        this.flyBehavior = flyBehavior;
    }

    public void setQuackBehavior(QuackBehavior quackBehavior) {
        this.quackBehavior = quackBehavior;
    }
}
